package com.adnaan.restaurant.mapper;

import com.adnaan.restaurant.entity.ResDishes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 菜品管理Mapper接口
 *
 * @author adnaan
 * @date 2023-10-11
 */
@Mapper
public interface ResDishesMapper {
    /**
     * 查询菜品详情
     *
     * @param id 菜品管理主键
     * @return 菜品管理
     */
    @Select("select d.id, d.name, d.pic, d.description, d.price, d.category, d.shop_id, s.name as shop_name from res_dishes d left join res_shop s on d.shop_id = s.id where d.id = #{did}")
    public ResDishes selectResDishesById(@Param("did") Long id);

    /**
     * 查询菜品管理列表
     *
     * @param resDishes 菜品管理
     * @return 菜品管理集合
     */
    @Select("select d.id, d.name, d.pic, d.description, d.price, d.category, d.shop_id, s.name as shop_name from res_dishes d left join res_shop s on d.shop_id = s.id where shop_id = #{sid}")
    public List<ResDishes> selectResDishesList(@Param("sid") Long shopId);


    @Select("select d.id, d.name, d.pic, d.description, d.price, d.category, d.shop_id, s.name as shop_name from res_dishes d left join res_shop s on d.shop_id = s.id where d.name like concat('%',#{name},'%')")
    List<ResDishes> selectResDishesByName(String name);
}
